package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * PROJECT_NAME: sky-take-out
 * NAME: OrdersMapper
 *
 * @AUTHOR: zhang
 * DATE: 2023/12/13
 * DESCRIPTION :
 */
@Mapper
public interface OrdersMapper {
    /**
     * 添加订单基本信息
     * @param orders
     */
    void insert(@Param("orders") Orders orders);

    /**
     * 基于userId查询订单
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> selectOrdersByUserId(@Param("ordersPageQueryDTO") OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 根据订单id查询订单基本信息
     * @param id
     * @return
     */
    Orders selectOrdersById(@Param("id") Long id);

    /**
     * 各个状态的订单数量统计
     * @param toBeConfirmed
     * @return
     */
    Integer getOrdersStatusNum(@Param("status") Integer toBeConfirmed);

    /**
     * 修改订单
     * @param orders
     */
    void updateOrders(@Param("orders") Orders orders);

    /**
     * 查询状态为未支付下单时间小于当前时间15分钟的订单
     * @param status
     * @param orderTime
     * @return
     */
    List<Orders> selectOvertimeAndUnpaidOrders(@Param("status") Integer status, @Param("orderTime") LocalDateTime orderTime);
}
